Skip to main content
POST
/
api
/
password-generator
/
save-passwords
/
Create Saved Password
curl --request POST \
  --url https://api.example.com/api/password-generator/save-passwords/ \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "user": 123,
  "password_saved": "<string>",
  "url": "<string>",
  "name_pages": "<string>"
}
'
{
  "user": ["This field is required."],
  "password_saved": ["This field is required."],
  "url": ["This field is required."]
}
Saves a password for a specific URL or page. Requires authentication.

Endpoint

POST /api/password-generator/save-passwords/

Authentication

Authorization
string
required
Bearer token for authentication. User must be logged in.

Request Body

user
integer
required
The user ID who is saving the password.
password_saved
string
required
The password to be saved (max 200 characters).
url
string
required
The URL where this password is used (max 200 characters).
name_pages
string
A friendly name for the page or service (max 200 characters).

Request Example

{
  "user": 1,
  "password_saved": "MySecureP@ss123",
  "url": "https://example.com",
  "name_pages": "Example Website"
}

Response

Success Response

200 OK
"password saved successfully"

Error Responses

{
  "user": ["This field is required."],
  "password_saved": ["This field is required."],
  "url": ["This field is required."]
}
{
  "error": "Missing required fields."
}
{
  "error": "password does not exist after creation."
}
{
  "error": "error message"
}

Example Request

curl -X POST https://api.example.com/api/password-generator/save-passwords/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "user": 1,
    "password_saved": "MySecureP@ss123",
    "url": "https://example.com",
    "name_pages": "Example Website"
  }'

Implementation Details

This endpoint is implemented in views.py:32 using the save_passwords view function. It validates the request data using SavedPasswordsSerializer and saves the password to the database associated with the authenticated user.